def greet_user1():
    # hello
    print("hello")

def greet_user(username):
    print("Hello," + username + "!")

greet_user1()
greet_user('Tim')

def display_message(lesson):
    print(lesson)

display_message('function')

def fav_books(book):
    print('One of my favourite book is ' + book)

fav_books('gushi')

def describle_pet(animal_type, pet_name):
    print('\nI have a ' + animal_type + "'s name is " + pet_name.title() + ".")

describle_pet(pet_name='chengxq', animal_type='humana')
describle_pet(animal_type='fish', pet_name='chengxq')


def describle_pet2(animal_type, pet_name='chengxq'):
    print('\nI have a ' + animal_type + "'s name is " + pet_name.title() + ".")


describle_pet2(animal_type='hunmannnnn')

def make_shirt(size, logo='I love python'):
    print('size: ' + size + ", logo:" + logo)

make_shirt('XL', 'Hahaha...')
make_shirt('XXXXL')
make_shirt('M')
make_shirt('S', 'hmmmmmmm')


def get_formatted_name(first_name, last_name):
    full_name = first_name + ' ' + last_name
    return full_name.title()

musician = get_formatted_name('xiaoqi', 'cheng')
print(musician)

def get_formatted_name2(fist_name, last_name, middle_name=''):
    if middle_name:
        full_name = fist_name + ' ' + middle_name + ' ' + last_name
    else:
        full_name = fist_name + ' ' + last_name
    return full_name

musician = get_formatted_name2('cheng', 'xiaoqi')
print(musician)

musician = get_formatted_name2('zou', 'you', 'zhong')
print(musician)

def build_person(first_name, last_name):
    person = {'first': first_name, 'last': last_name}
    return person

musician = build_person('cheng','xiaoqi') 
print(musician)

def build_person2(first_name, last_name, age=''):
    person = {'first': first_name, 'last': last_name}
    if age:
        person['age'] = age

    return person

musician = build_person2('cheng', 'xiaoqi', '30')
print(musician)


# def loop_build_person():
#     while True:
#         print('\nPlease tell me your name:')
#         f_name = input('First name: ')
#         l_name = input('Last name: ')

#         formatted_name = get_formatted_name(f_name, l_name)
#         print('\nHello, ' + formatted_name + '!') 

# loop_build_person()


def loop_build_person2():
    while True:
        print('\nPlease tell me your name:')
        print('(enter "q" at any time to quit)')    

        f_name = input('First name: ')
        if f_name == 'q':
            break

        l_name = input('Last name: ')
        if l_name == 'q':
            break

        formatted_name = get_formatted_name(f_name, l_name)
        print('\nHello, ' + formatted_name + '!')

# loop_build_person2()


def print_city(city,  province):
    print("\n'" + city + "','" + province + "'")

print_city('hangzhou', 'zhejiang')
print_city('shanghai', 'shanghai')
print_city('fuzhou', 'fujian')

def make_album(singer, album):
    album = {'singer': singer, 'album': album}
    return album

album = make_album('zhangsan', 'zs')
print(album)
album = make_album('wangwu', 'ww')
print(album)


def make_album2(singer, album, size=''):
    album = {'singer': singer, 'album': album}
    if size:
        album['size'] = size
    return album

album = make_album2('zhangsan', 'zs', 10)
print(album)

def greet_users(unames):
    for name in unames:
        msg = "hello," + name.title() + "!"
        print(msg)


usernames = ['hannah', 'ty', 'margot']
greet_users(usernames)  

unprinted_designs = ['iphone case', 'robot pendant', 'dodecahedron']
completed_models = []

while unprinted_designs:
    current_design = unprinted_designs.pop()

    print('Printing model:' + current_design)
    completed_models.append(current_design)

print("\nThe following models have been printed:")
for completed_model in completed_models:
    print(completed_model)

